package com.chengqs.chapter03;

import android.view.ViewGroup;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.chengqs.chapter03.util.Utils;

public class ViewBorderActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_border);

        TextView tvCode = findViewById(R.id.tv_code);
        // 获取tv_code的布局参数
        ViewGroup.LayoutParams layoutParams = tvCode.getLayoutParams();
        // 设置宽度为0，注意默认px单位，需要把dp数值转换为px单位
        layoutParams.width = Utils.dip2px(this, 300);
        tvCode.setLayoutParams(layoutParams);
    }
}